Page({
  data: {
    typeIndex: 0,
    difficultyIndex: 0,
    types: ['全部', '单选题', '多选题', '判断题'],
    difficulties: ['全部', '简单', '中等', '困难'],
    questions: [
      {
        id: 1,
        type: '单选题',
        content: '在Word中，下列哪个快捷键可以实现文字加粗？',
        difficulty: '简单',
        count: 128
      },
      {
        id: 2,
        type: '判断题',
        content: 'Excel中，函数SUM可以计算一组数值的平均值。',
        difficulty: '中等',
        count: 89
      }
    ]
  },

  onLoad() {
    this.loadQuestions()
  },

  onSearch(e) {
    const keyword = e.detail.value
    // 实现搜索功能
  },

  onTypeChange(e) {
    this.setData({
      typeIndex: e.detail.value
    })
    this.loadQuestions()
  },

  onDifficultyChange(e) {
    this.setData({
      difficultyIndex: e.detail.value
    })
    this.loadQuestions()
  },

  loadQuestions() {
    // 根据筛选条件加载题目
  },

  goToQuestion(e) {
    const id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: `/pages/exercise/exercise?id=${id}&mode=practice`
    })
  }
}) 